package com.rz.paas.test.constant

import android.app.Activity
import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.view.View.X
import android.widget.Toast
import java.io.InputStream

fun Context.screenHeight():Int{
   return resources.displayMetrics.heightPixels
}

fun Activity.toast(str: String){
   Toast.makeText(this, str, Toast.LENGTH_SHORT).show()
}

fun Context.readBitMap( resId: Int): Bitmap? {
   val opt: BitmapFactory.Options = BitmapFactory.Options()

   opt.inPreferredConfig = Bitmap.Config.RGB_565 //表示16位位图 565代表对应三原色占的位数
   opt.inSampleSize = 1
   opt.inPurgeable = true //设置图片可以被回收
   opt.inInputShareable = true //获取图片资源
   val inputStream: InputStream = resources.openRawResource(resId)
   return BitmapFactory.decodeStream(inputStream, null, opt)
}